//
//  TKL_BLogDetailVC.m
//  TKL_EnPro
//
//  Created by 雅恩三河科技 on 2018/12/11.
//  Copyright © 2018年 MrZhang. All rights reserved.
//

//
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                  \\`.
//        .'//                     |                     \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
//    .'//.-"                 `-.  |  .-'                 "-.\\`.
//  .'//______.============-..   \ | /   ..-============.______\\`.
//.'______________________________\|/______________________________`.
//
//

#import "TKL_BLogDetailVC.h"
#import "TKL_blogCommentCell.h"
#import "TKL_LoginViewModel.h"
@interface TKL_BLogDetailVC ()<UIWebViewDelegate,UITextFieldDelegate>
{
    NSInteger currentPage;
}
@property(nonatomic,strong)NSMutableArray* dataSource;
@property(nonatomic,strong)NSMutableDictionary* detailData;
@property (nonatomic, strong) UIButton *commentBtn;
@property(nonatomic,strong)UIWebView* imageWebView;


@property (nonatomic,strong) UIView *btomView;
@property (nonatomic,strong) UIButton *priseBtn;
@property (nonatomic,strong) UITextField *inputTF;
@property (nonatomic,strong) UIImageView *myHHIV;

@end

@implementation TKL_BLogDetailVC
-(UIImageView *)myHHIV
{
    if (!_myHHIV)
    {
        _myHHIV=[UIImageView new];
        _myHHIV.width=WFCGFloatY(375-20);
        _myHHIV.height=WFCGFloatY(180);
        _myHHIV.x=WFCGFloatX(10);
        _myHHIV.contentMode=UIViewContentModeScaleAspectFill;
        _myHHIV.layer.masksToBounds=YES;


    }
    return _myHHIV;
}

-(UITextField *)inputTF
{
    if (!_inputTF) {
        _inputTF = [[UITextField alloc]init];
        _inputTF.x=WFCGFloatX(15);
        _inputTF.y=WFCGFloatY(7);
        _inputTF.width=WFCGFloatX(310);
        _inputTF.height=WFCGFloatY(32);
        _inputTF.font = SYSTEMFONT(15);
        _inputTF.textColor = Main_Color_Black;
        _inputTF.delegate = self;
        _inputTF.placeholder=@"添加评论";
        _inputTF.returnKeyType=UIReturnKeySend;
        [WFFunctions WFUIaddbordertoView:_inputTF radius:0 width:1 color:HEXCOLOR(@"#EEEEEE")];
        
        UIView* backView=[UIView new];
        backView.x=WFCGFloatX(0);
        backView.y=WFCGFloatY(0);
        backView.height=WFCGFloatY(32);
        backView.width=WFCGFloatX(32);
        backView.backgroundColor=HEXCOLOR(@"#F9F9F9");
        
        
        UIImageView* markIV=[UIImageView new];
        markIV.image=[UIImage imageNamed:@"new_edite"];
        markIV.width=WFCGFloatX(12);
        markIV.height=WFCGFloatX(12);
        markIV.x=WFCGFloatX(10);
        markIV.y=(backView.height-markIV.height)/2;
        [backView addSubview:markIV];
        _inputTF.leftView=backView;
        _inputTF.leftViewMode=UITextFieldViewModeAlways;
    }
    return _inputTF;
}
-(UIButton *)priseBtn
{
    if (!_priseBtn) {
        @WeakSelf;
        _priseBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        UIImage* image1=[UIImage imageNamed:@"new_praise_sel"];
        UIImage* image=[UIImage imageNamed:@"new_praise"];
        [_priseBtn setBackgroundImage:image forState:UIControlStateNormal];
        [_priseBtn setBackgroundImage:image1 forState:UIControlStateSelected];
        _priseBtn.width=WFCGFloatX(26);
        _priseBtn.height=WFCGFloatX(26);
        _priseBtn.x=WFCGFloatX(334);
        _priseBtn.y=(WFCGFloatY(45)-_priseBtn.height)/2;
        [_priseBtn setEnlargeEdge:15];
        [_priseBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
            
            if ([TKL_LoginViewModel shareInterface].isLogin)
            {
                selfp.priseBtn.selected=!selfp.priseBtn.selected;
            }else
            {
                [[GCPresenter shareInterface] loadLogin];
            }
        }];
    }
    return _priseBtn;
}
-(UIView *)btomView
{
    if (!_btomView)
    {
        _btomView=[UIView new];
        _btomView.x=WFCGFloatX(0);
        _btomView.y= SCREEN_HEIGHT-[self bottomShelterHeight]-WFCGFloatY(45);
        _btomView.height=WFCGFloatY(45);
        _btomView.width=WFCGFloatX(375);
        _btomView.backgroundColor=HEXCOLOR(@"#F9F9F9");
        
        [WFFunctions WFUIaddBorderToView:_btomView top:1 left:0 bottom:0 right:0 borderColor:HEXCOLOR(@"#EEEEEE") borderWidth:1];
    }
    return _btomView;
}



-(UIWebView *)imageWebView
{
    if (!_imageWebView) {
        _imageWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,1)];
        _imageWebView.scrollView.showsVerticalScrollIndicator = NO;
        _imageWebView.scrollView.showsHorizontalScrollIndicator = NO;
        _imageWebView.backgroundColor=[UIColor whiteColor];
        _imageWebView.scrollView.scrollEnabled = NO;
        _imageWebView.delegate = self;
        [_imageWebView setScalesPageToFit:NO];
        if (@available(iOS 11.0, *)) {
            _imageWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
        
    }
    return _imageWebView;
}
-(UIButton *)commentBtn
{
    if (!_commentBtn)
    {
        @WeakSelf;
        _commentBtn = [[UIButton alloc]init];
        
        _commentBtn.width=SCREEN_WIDTH;
        _commentBtn.height=WFCGFloatY(40);
        _commentBtn.x=0;
        _commentBtn.y=SCREEN_HEIGHT-WFCGFloatY(40);
        [_commentBtn setTitle:@"添加评论" forState:UIControlStateNormal];
        [_commentBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _commentBtn.backgroundColor=Main_Color;
        _commentBtn.titleLabel.font = SYSTEMFONT(15);
        [_commentBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
            
            if ([TKL_LoginViewModel shareInterface].isLogin)
            {
                TYAlertView *alertView = [TYAlertView alertViewWithTitle:@"评价内容" message:@""];
                [alertView addAction:[TYAlertAction actionWithTitle:@"取消" style:TYAlertActionStyleCancel handler:^(TYAlertAction *action) {
                    NSLog(@"%@",action.title);
                }]];
                
                // 弱引用alertView 否则 会循环引用
                __typeof (alertView) __weak weakAlertView = alertView;
                [alertView addAction:[TYAlertAction actionWithTitle:@"确定" style:TYAlertActionStyleDestructive handler:^(TYAlertAction *action) {
                    for (UITextField *textField in weakAlertView.textFieldArray) {
                        NSLog(@"%@",textField.text);
                        if ([WFFunctions WFStrCheckEmpty:textField.text]) {
                            [FTIndicator showErrorWithMessage:@"请填写评价内容"];
                        }else
                        {
                            [selfp requestAddComment:textField.text];
                        }
                    }
                }]];
                
                [alertView addTextFieldWithConfigurationHandler:^(UITextField *textField) {
                    [textField becomeFirstResponder];
                    
                }];
                // first way to show
                TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:alertView preferredStyle:TYAlertControllerStyleAlert];
                alertController.backgoundTapDismissEnable=YES;
                alertController.alertViewOriginY=[self topShelterHeight]+60;
                [selfp presentViewController:alertController animated:YES completion:nil];
                
            }else
            {
                [[GCPresenter shareInterface] loadLogin];
            }
            
        }];
    }
    return _commentBtn;
}
-(NSMutableDictionary *)detailData
{
    if (!_detailData)
    {
        _detailData=[NSMutableDictionary new];
    }
    return _detailData;
}
-(NSMutableArray *)dataSource
{
    if (!_dataSource) {
        _dataSource=[NSMutableArray new];
    }
    return _dataSource;
}
#pragma mark - event
#pragma mark - method
-(void)initilization
{
    self.isGroup = YES;
    currentPage=1;
    @WeakSelf;
    self.navigationItem.title =@"帖子";
    [self setRightBarButtonWithTitle:@"举报" titleColor:HEXCOLOR(@"#666666") withBlock:^{

        if ([TKL_LoginViewModel shareInterface].isLogin)
        {
            Class class=NSClassFromString(@"TKL_BlogreVC");
            UIViewController* vc=[[class alloc] init];
            [selfp.navigationController pushViewController:vc animated:YES];
            
        }else
        {
            [[GCPresenter shareInterface] loadLogin];
        }
    }];
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.baseTable.contentInset = UIEdgeInsetsMake([self topShelterHeight], 0, [self bottomShelterHeight]+WFCGFloatY(45), 0);
    self.view.backgroundColor = Main_Color_BG;
    
    [self.view addSubview:self.baseTable];
   // [self.view addSubview:selfp.commentBtn];
    
    
    [self.view addSubview:self.btomView];
    [self.btomView addSubview:self.inputTF];
    [self.btomView addSubview:self.priseBtn];
    
    [self.baseTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.baseTable setSeparatorColor:Main_Color_BG];
    [self viewModelBand];
    
    
    self.baseTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{

        [selfp reloadData];
        [selfp.baseTable.mj_header endRefreshing];
    }];

    [selfp reloadData];
}
-(void)viewModelBand
{
    @WeakSelf;

}
-(void)reloadListData
{
    NSMutableDictionary* para=[NSMutableDictionary new];
    [self requestCityData:para];
    [self requestCommnet:para];
}
-(void)reloadData
{
    [self reloadListData];
}
-(void)reloadView
{
    
}
#pragma mark - life

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initilization];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==2) {
        return self.dataSource.count;
    }
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    @WeakSelf;
    
    
    if (indexPath.section==0)
    {
        static NSString* identify=@"PPthreePhonecell";
        UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:identify];
        if (!cell) {
            cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identify];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            cell.backgroundColor=[UIColor whiteColor];
        }
        [cell.contentView removeAllSubviews];
        
        
        UILabel* titleLavb=[UILabel new];
        titleLavb.x=WFCGFloatX(20);
        titleLavb.y=WFCGFloatY(10);
        titleLavb.width=WFCGFloatX(335);
        titleLavb.height=WFCGFloatY(40);
        titleLavb.textColor=HEXCOLOR(@"#333333");
        titleLavb.font=SYSTEMFONT(15);
        [cell.contentView addSubview:titleLavb];
        titleLavb.numberOfLines=2;
        titleLavb.text=[WFFunctions WFCheckEmptyBackStr:[self.detailData objectForKey:@"title"]];
        
        
        
        UIImageView* markIV=[UIImageView new];
        markIV.width=WFCGFloatY(40);
        markIV.height=WFCGFloatY(40);
        markIV.x=WFCGFloatX(20);
        markIV.y=WFCGFloatY(15+40);
        [WFFunctions WFUIaddbordertoView:markIV radius:WFCGFloatX(35/2) width:0 color:[UIColor clearColor]];
        [cell.contentView addSubview:markIV];
        [markIV sd_setImageWithURL:[NSURL URLWithString:[WFFunctions WFCheckEmptyBackStr:[[self.detailData objectForKey:@"author"] objectForKey:@"avatar"]]] placeholderImage:DefaultAvatarMImage];

        UILabel* autLab=[UILabel new];
        autLab.x=WFCGFloatX(70);
        autLab.y=WFCGFloatY(20+40);
        autLab.width=WFCGFloatX(200);
        autLab.height=WFCGFloatY(12);
        autLab.textColor=YN_Light_Gray_Color;
        autLab.font=SYSTEMFONT(12);
        [cell.contentView addSubview:autLab];
        autLab.text=[WFFunctions WFCheckEmptyBackStr:[[self.detailData objectForKey:@"author"] objectForKey:@"nickname"]];

        UILabel* timeLab=[UILabel new];
        
        timeLab.y=WFCGFloatY(38+40);
        timeLab.width=WFCGFloatX(200);
        timeLab.textColor=YN_Light_Gray_Color;
        timeLab.height=WFCGFloatY(12);
        timeLab.x=WFCGFloatX(70);
        timeLab.font=SYSTEMFONT(11);
        [cell.contentView addSubview:timeLab];
        timeLab.text= [WFFunctions getDateWithTimeStamp:[WFFunctions WFCheckEmptyBackStr:[self.detailData objectForKey:@"createTime"]] formatter:@"yyyy-mm-dd"];

        return cell;
    }
    
    if (indexPath.section==1)
    {
        static NSString *CellID = @"CellIDThird1";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor=[UIColor whiteColor];
            [cell.contentView addSubview:self.imageWebView];
            [cell.contentView addSubview:self.myHHIV];
            

        }
        if (![WFFunctions WFStrCheckEmpty:[self.detailData objectForKey:@"cover"]]) {
            self.myHHIV.hidden=NO;
            _myHHIV.y=self.imageWebView.frame.size.height+WFCGFloatY(10);
            [_myHHIV sd_setImageWithURL:[NSURL URLWithString:[self.detailData objectForKey:@"cover"]] placeholderImage:DefaultAvatarMImage];
            
        }else
        {
            self.myHHIV.hidden=YES;
        }

            
        return cell;
    }
    static NSString* identify=@"PPthreePhonecell1111";
    TKL_blogCommentCell* cell=[tableView dequeueReusableCellWithIdentifier:identify];
    if (!cell) {
        cell=[[TKL_blogCommentCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identify];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.backgroundColor=[UIColor whiteColor];
    }
    [cell setModel:self.dataSource[indexPath.row]];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // return self.imageWebView.frame.size.height;
    if (indexPath.section==0) {
        return WFCGFloatY(70+40);
    }
    if (indexPath.section==1)
    {
        if ([WFFunctions WFStrCheckEmpty:[self.detailData objectForKey:@"cover"]]) {
            return self.imageWebView.frame.size.height;
        }
        return self.imageWebView.frame.size.height+WFCGFloatY(200);
    }

    NSDictionary* dic=self.dataSource[indexPath.row];
    CGSize temSize=[WFFunctions WFStrGetSize:[dic objectForKey:@"content"] width:SCREEN_WIDTH-WFCGFloatX(55) font:SYSTEMFONT(12)];
    return WFCGFloatY(50)+temSize.height+WFCGFloatY(5);

}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView* view=[[UIView alloc] init];
    view.backgroundColor=[UIColor whiteColor];
    if (section==2)
    {
        UILabel* autLab=[UILabel new];
        autLab.x=WFCGFloatX(10);
        autLab.y=WFCGFloatY(0);
        autLab.width=WFCGFloatX(200);
        autLab.height=WFCGFloatY(40);
        autLab.textColor=HEXCOLOR(@"#333333");
        autLab.font=SYSTEMFONT(15);
        [view addSubview:autLab];
        autLab.text=@"评价";
    }
    
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section==2) {
        return WFCGFloatY(40);
    }
    return .0001f;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView* view=[UIView new];
    view.backgroundColor=Main_Color_BGLightGray;
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return WFCGFloatY(10);
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    
}
-(void)requestCityData:(NSMutableDictionary *)para
{
    @WeakSelf;
    [FTIndicator showProgressWithMessage:@"正在加载"];
    if (![WFFunctions WFStrCheckEmpty:[TKL_LoginViewModel shareInterface].infoModel.uuid])
    {
        [para setObject:[TKL_LoginViewModel shareInterface].infoModel.uuid forKey:@"userUuid"];
    }
    
    [para setObject:_blogID forKey:@"posterUuid"];
    [[InterfaceManager shareInterface] requestAllInterface:@"http://101.201.171.131:8080/rest/api/community/poster/detail" para:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [selfp.detailData removeAllObjects];
        selfp.detailData =[[NSMutableDictionary alloc] initWithDictionary:[info objectForKey:@"data"]];
       // [selfp.imageWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];
      //  [selfp.imageWebView loadHTMLString:[selfp.detailData objectForKey:@"content"] baseURL:nil];
        
        NSString *hetmls = @"<!DOCTYPE html><html><head lang='en'><meta charset='UTF-8'><title></title><style>img {display: block;width: 100%;margin-top: 10px;margin-bottom: 10px;}[contenteditable=true]:empty:before {content: attr(placeholder);color: #a6a6a6;}#content {padding: 10px 0;font-family: Helvetica;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);min-height: 100px;}</style></head><body><div>";
        hetmls = [hetmls stringByAppendingString:[selfp.detailData objectForKey:@"content"] ?: @""];
        hetmls = [hetmls stringByAppendingString:@"</div></body/html>"];
        
        dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            [selfp.imageWebView loadHTMLString:hetmls baseURL:nil];
        });
        
        
        [selfp.baseTable reloadData];
    }];

}
-(void)requestCommnet:(NSMutableDictionary*)para
{
    @WeakSelf;
    //base=0&onlyLandlord=0&page=1&posterUuid=07d7b549-5752-498c-9a8d-b078229b3187
    
    [para setObject:@"0" forKey:@"base"];
    [para setObject:_blogID forKey:@"posterUuid"];
    [para setObject:@"0" forKey:@"onlyLandlord"];
    [para setObject:@"1" forKey:@"page"];
    
    [[InterfaceManager shareInterface] requestAllInterface:@"http://101.201.171.131:8080/rest/api/community/comment/list" para:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [selfp.dataSource removeAllObjects];
        NSArray* arr=[info objectForKey:@"dataList"];
        for (NSDictionary* dic in arr) {
            [selfp.dataSource addObject:dic];
        }
        [selfp.baseTable reloadData];
    }];
    
    
}
-(void)requestAddComment:(NSString*)content
{
    //http://101.201.171.131:8080/rest/api/community/comment/add
    NSMutableDictionary* para=[NSMutableDictionary new];
    [para setObject:content forKey:@"content"];
    [para setObject:@"[]" forKey:@"imgList"];
    [para setObject:[TKL_LoginViewModel shareInterface].infoModel.uuid forKey:@"userUuid"];
    [para setObject:_blogID forKey:@"posterUuid"];
    [[InterfaceManager shareInterface] requestAllInterface:@"http://101.201.171.131:8080/rest/api/community/comment/add" para:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [self requestCommnet:[NSMutableDictionary new]];
    }];
}
-(void)requestPPAddComment:(NSString*)content
{
    //http://101.201.171.131:8080/rest/api/community/comment/add
    NSMutableDictionary* para=[NSMutableDictionary new];
    [para setObject:content forKey:@"content"];
    [para setObject:[TKL_LoginViewModel shareInterface].infoModel.uuid forKey:@"userUuid"];

    
    [[InterfaceManager shareInterface] requestAllInterface:@"http://101.201.171.131:8080/rest/api/user/report/add" para:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [FTIndicator showSuccessWithMessage:@"感谢您的举报,我们会尽快处理"];
    }];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    CGFloat height = [[self.imageWebView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue];
    self.imageWebView.frame = CGRectMake(0,0, SCREEN_WIDTH, height);
    [FTIndicator dismissProgress];
    [self.baseTable reloadData];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSLog(@"哈哈哈");
    if ([TKL_LoginViewModel shareInterface].isLogin)
    {
        if ([WFFunctions WFStrCheckEmpty:textField.text]) {
            [FTIndicator showErrorWithMessage:@"请填写评价内容"];
        }else
        {
            [self requestAddComment:textField.text];
            self.inputTF.text=@"";
        }
        
    }else
    {
        [[GCPresenter shareInterface] loadLogin];
    }
    [self.inputTF resignFirstResponder];
    return YES;
}

@end


/*
 11111111111111111111111111111111111111001111111111111111111111111
 11111111111111111111111111111111111100011111111111111111111111111
 11111111111111111111111111111111100001111111111111111111111111111
 11111111111111111111111111111110000111111111111111111111111111111
 11111111111111111111111111111000000111111111111111111111111111111
 11111111111111111111111111100000011110001100000000000000011111111
 11111111111111111100000000000000000000000000000000011111111111111
 11111111111111110111000000000000000000000000000011111111111111111
 11111111111111111111111000000000000000000000000000000000111111111
 11111111111111111110000000000000000000000000000000111111111111111
 11111111111111111100011100000000000000000000000000000111111111111
 11111111111111100000110000000000011000000000000000000011111111111
 11111111111111000000000000000100111100000000000001100000111111111
 11111111110000000000000000001110111110000000000000111000011111111
 11111111000000000000000000011111111100000000000000011110001111111
 11111110000000011111111111111111111100000000000000001111100111111
 11111111000001111111111111111111110000000000000000001111111111111
 11111111110111111111111111111100000000000000000000000111111111111
 11111111111111110000000000000000000000000000000000000111111111111
 11111111111111111100000000000000000000000000001100000111111111111
 11111111111111000000000000000000000000000000111100000111111111111
 11111111111000000000000000000000000000000001111110000111111111111
 11111111100000000000000000000000000000001111111110000111111111111
 11111110000000000000000000000000000000111111111110000111111111111
 11111100000000000000000001110000001111111111111110001111111111111
 11111000000000000000011111111111111111111111111110011111111111111
 11110000000000000001111111111111111100111111111111111111111111111
 11100000000000000011111111111111111111100001111111111111111111111
 11100000000001000111111111111111111111111000001111111111111111111
 11000000000001100111111111111111111111111110000000111111111111111
 11000000000000111011111111111100011111000011100000001111111111111
 11000000000000011111111111111111000111110000000000000011111111111
 11000000000000000011111111111111000000000000000000000000111111111
 11001000000000000000001111111110000000000000000000000000001111111
 11100110000000000001111111110000000000000000111000000000000111111
 11110110000000000000000000000000000000000111111111110000000011111
 11111110000000000000000000000000000000001111111111111100000001111
 11111110000010000000000000000001100000000111011111111110000001111
 11111111000111110000000000000111110000000000111111111110110000111
 11111110001111111100010000000001111100000111111111111111110000111
 11111110001111111111111110000000111111100000000111111111111000111
 11111111001111111111111111111000000111111111111111111111111100011
 11111111101111111111111111111110000111111111111111111111111001111
 11111111111111111111111111111110001111111111111111111111100111111
 11111111111111111111111111111111001111111111111111111111001111111
 11111111111111111111111111111111100111111111111111111111111111111
 11111111111111111111111111111111110111111111111111111111111111111
 
 
 */
